package com.easytouch.core;

import android.content.Context;


import com.easytouch.core.utils.FileTools;
import com.easytouch.core.utils.Log;

import java.io.File;
import java.io.IOException;

public class CopyProFileThread extends Thread {
    private String proNewFilePath = FileTools.getSDCardPath() + "/alipay/iotsdk/runtime";
    private String proNewFile = proNewFilePath + "/profile.dat";
    private Context context;
    private Log logger = new Log("CopyProFileThread.txt");

    public CopyProFileThread(Context context) {
        this.context = context;
    }

    @Override
    public void run() {
        super.run();
        File file = new File(proNewFilePath);
        File file1 = new File(proNewFile);
        if (!file.exists()) {
            logger.i("文件夹不存在，正在新建。。。");
            boolean newFile = file.mkdirs();
            if (newFile) {

                //                    file1.createNewFile();
                FileTools.copyFilesFassets(context, "profile.dat", proNewFile);

            }
            logger.i("新建成功");
        }else{
            if (!file1.exists()){
                try {
                    file1.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        FileTools.copyFilesFassets(context, "profile.dat", proNewFile);

    }
}
